Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env variable which controls if auto launch is enabled or not #573

Merged

Conversation

johnksv
Copy link
Contributor

@johnksv johnksv commented Aug 16, 2023

Keep old behaviour of allowing auto launch by default.

The user will land at the service launcher if the URL specifies autoLaunch=true when auto launch is disabled, as shown in this video:

Screen.Recording.2023-08-16.at.15.03.42.mov

Discussion: Should the user get an alert or a notification that the service tried to auto launch but failed to due the configuration of onyxia-web? I vote no. One reason is there are no need for the user to have a concept of "autolaunch" and whenever or not the autoLaunch "fail".

Closes #548

src/ui/env.ts Show resolved Hide resolved
@garronej
Copy link
Contributor

Love it, thanks a lot!

@fcomte
Copy link
Contributor

fcomte commented Aug 16, 2023

Thx @johnksv
I am not sure how we should handle this forbid.

For example with this capture , I see that all the parameter will be kept from the query string..
The user will maybe just click to launch the service and it's still quite dangerous for him.

What do you think of this scenario ?

@garronej
Copy link
Contributor

Hello again,

There is an important aspect that we need to address in this PR.

When a user initiates one of their saved configurations from the MyServices page, it effectively triggers an auto launch. We need to ensure that this feature remains functional even when auto-launching is restricted by the Onyxia administrator.

There are two strategies to achieve this:

  1. Handle it at the UI (React) Level:
    Before launching the service, we can check if the user is navigating from the MyServices page. If that is the case, we can enable auto-launch, overriding any explicit restrictions, since this is known to be an internal action.
    To implement this, you would need to use a getPreviousRouteName() function, an example of which can be found here. This code is from a project with a similar architecture to Onyxia, so it can be copied directly into onyxia-web.

  2. Handle it at the Core Level:
    Add an isAutoLaunch parameter to the launch() function and allow the core to determine if the service should be launched. The core can determine whether we are launching a service with a configuration saved by the user, thereby bypassing the restriction.

    The potential implementation could look like this:
    src/core/usecases/launcher.ts

    "launch":
        (params: { isAutoLaunch: boolean; }) =>
            async (...args) => {
    
                const { isAutoLaunch } = params;
    
                const [dispatch, getState, { createStoreParams: { isAutoLaunchAllowed } }] = args;
    
                prevent_auto_launch: {
    
                    if (!isAutoLaunch) {
                        break prevent_auto_launch;
                    }
    
                    if (isAutoLaunchAllowed) {
                        break prevent_auto_launch;
                    }
    
                    const isAutoLaunchingSavedConfiguration =
                        dispatch(restorablePackageConfigs.thunks.getIsRestorablePackageConfigInStore({
                            "restorablePackageConfigs": getState().restorablePackageConfig.restorablePackageConfigs,
                            "restorablePackageConfig": (() => {
    
                                const restorablePackageConfig = selectors.restorablePackageConfig(getState());
    
                                assert(restorablePackageConfig !== undefined, "Launcher must be initialized before auto launching");
    
                                return restorablePackageConfig;
    
                            })()
                        }));
    
                    if (isAutoLaunchingSavedConfiguration) {
                        break prevent_auto_launch;
                    }
    
                    // Actually preventing auto launch
                    return;
                }
    
                dispatch(
                    privateThunks.launchOrPreviewContract({
                        "isForContractPreview": false
                    })
                );
            },

    The createCore function would need to be updated to accept an additional parameter like isAutoLaunchAllowed.

Would you be willing to implement one of these solutions? If it seems too time-consuming, I would be more than happy to assist or take over the implementation.

For example, with this capture, I see that all the parameters will be retained from the query string. The user may simply click to launch the service, which can still be risky.

Regarding this, @fcomte and I discussed over the phone and agreed that with the x-security feature, we are providing a means to implement more stringent and fine-grained security measures. We should, therefore, concentrate on refining this feature and aim to keep the auto-launch prevention mechanism simple and straightforward.

Thank you for your time and contributions to this project.

Best,

@johnksv
Copy link
Contributor Author

johnksv commented Aug 17, 2023

Hi!
Thank you for your elaborate answer. The functionality of launching a saved configuration form the MyServices page is one that I was not aware of.
I have no strong opinion on which approach that would be best suited, so please feel free to recommend/go with the one you are most comfortable/think is best.
The effort I put into this will be on the side, and therefore limited.
If you would like to take over the implementation that is no problem for me (the end goal for me is to get this implemented in a good way, so who does it goes for the same 😅).

Keep old behaviour of allowing auto launch by default.
@johnksv
Copy link
Contributor Author

johnksv commented Aug 22, 2023

Rebased on main

@garronej
Copy link
Contributor

Hello @johnksv,

I apologize for not providing timely feedback on your Pull Request. Given that it's been inactive for two weeks, I'll take over from this point.

Moving forward, you can expect quicker responses from me on any future PRs, as I have now resumed full-time work on Onyxia.

Thank you for your understanding.

Best regards,

@garronej garronej merged commit 164666d into InseeFrLab:main Aug 29, 2023
5 checks passed
@johnksv johnksv deleted the option-disable-auto-launch branch August 29, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deactivate autolaunch
3 participants